{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "---\n",
    "sidebar_position: 0.1\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# SQL\n",
    "\n",
    "One of the most common types of databases that we can build Q&A systems for are SQL databases. LangChain comes with a number of built-in chains and agents that are compatible with any SQL dialect supported by SQLAlchemy (e.g., MySQL, PostgreSQL, Oracle SQL, Databricks, SQLite). They enable use cases such as:\n",
    "\n",
    "* Generating queries that will be run based on natural language questions,\n",
    "* Creating chatbots that can answer questions based on database data,\n",
    "* Building custom dashboards based on insights a user wants to analyze,\n",
    "\n",
    "and much more.\n",
    "\n",
    "## ⚠️ Security note ⚠️\n",
    "\n",
    "Building Q&A systems of SQL databases requires executing model-generated SQL queries. There are inherent risks in doing this. Make sure that your database connection permissions are always scoped as narrowly as possible for your chain/agent's needs. This will mitigate though not eliminate the risks of building a model-driven system. For more on general security best practices, [see here](/docs/security).\n",
    "\n",
    "![sql_usecase.png](../../../static/img/sql_usecase.png)\n",
    "\n",
    "## Quickstart\n",
    "\n",
    "Head to the **[Quickstart](/docs/use_cases/sql/quickstart)** page to get started.\n",
    "\n",
    "## Advanced\n",
    "\n",
    "Once you've familiarized yourself with the basics, you can head to the advanced guides:\n",
    "\n",
    "* [Agents](/docs/use_cases/sql/agents): Building agents that can interact with SQL DBs.\n",
    "* [Prompting strategies](/docs/use_cases/sql/prompting): Strategies for improving SQL query generation.\n",
    "* [Query validation](/docs/use_cases/sql/query_checking): How to validate SQL queries.\n",
    "* [Large databases](/docs/use_cases/sql/large_db): How to interact with DBs with many tables and high-cardinality columns."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "poetry-venv",
   "language": "python",
   "name": "poetry-venv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
